<?php
class Infrastructure_Factory
{
    /**
     * @var Infrastructure_Configuration
     */
    protected $configuration;

    /**
     * @return PDO
     */
    public function createPDO()
    {
        static $instance;
        $pdo = ($instance)
            ? $instance
            : new PDO($this->configuration->getDSN(),
                $this->configuration->getDatabaseUser(),
                $this->configuration->getDatabasePassword()
            );
        $pdo->query("SET GLOBAL time_zone=:timezone", array('timezone' => $this->configuration->getDatabaseTimeZone()));
        return $pdo;
    }

    /**
     * @param Infrastructure_Configuration $configuration
     */
    public function __construct(Infrastructure_Configuration $configuration)
    {
        $this->configuration = $configuration;
    }
}